﻿using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Collections;

namespace DAL
{
    /// <summary>
    /// Author: Sissi Zeng
    /// Date:2012 08-08 15:00
    /// Read and Write from/into Table Teacher
    /// </summary>
    public class Teacher
    {
      
        /// <summary>
        /// Construtor
        /// </summary>
        public Teacher()
        {

        }



        /// <summary>
        /// select a certain column from table Teacher in database
        /// </summary>
        /// <param name="column">column name</param>
        /// <returns>ResultSet in DataReader </returns>
        public SqlDataReader getListBy(string column)
        {
            string sqlStr = "select " + column + " from Teacher";
            using (SqlDataReader dr = SQLHelper.ExcuteReader(SQLHelper.ConnectionStringProjectb, CommandType.Text, sqlStr, null))
            {
                return dr;

            }
            
        }

        /// <summary>
        /// select all column from table Teacher in database
        /// </summary>s
        /// <returns>ResultSet in DataSet</returns>
        public DataSet getAll()
        {
            DataSet ds = new DataSet();
            using(SqlConnection conn=new SqlConnection(SQLHelper.ConnectionStringProjectb))
            {
                conn.Open();
                string selectStatement = "select * from Teacher";
                SqlDataAdapter da = new SqlDataAdapter(selectStatement, conn);
                ds = new DataSet();
                da.Fill(ds, "TeacherList");
                
            }
            return ds;
            
        }

    }
}
